﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AppSocketService.DeviceRstTypeCntService;
using BCGPSCommon;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BCGPSRESTful.Controllers.Page.DeviceRstTypeCnt
{
    /// <summary>
    /// 设备重启类型统计  -- 系统功能
    /// </summary>
    [ApiExplorerSettings(GroupName = "SystemAccount")]
    [Route("api/[controller]")]
    [ApiController]
    public class DeviceRstTypeCntController : PageBaseController
    {
        private readonly IDeviceRstTypeCntService deviceRstTypeCntService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="deviceRstTypeCntService"></param>
        public DeviceRstTypeCntController(IDeviceRstTypeCntService deviceRstTypeCntService)
        {
            this.deviceRstTypeCntService = deviceRstTypeCntService;
        }

        /// <summary>
        /// 查询设备重启类型统计
        /// </summary>
        /// <param name="imei"></param>
        /// <param name="start">开始时间</param>
        /// <param name="end">结束时间</param>
        /// <param name="desc">是否倒序</param>
        /// <param name="index">页码</param>
        /// <param name="size">记录数</param>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(PageableList<AppSocketModel.DeviceRstTypeCnt>), 200)]
        public PageableList<AppSocketModel.DeviceRstTypeCnt> QueryListPage(string imei, DateTime? start, DateTime? end, bool? desc = false, int? index = 0, int? size = 20)
        {
            if (!start.HasValue)
                start = DateTime.Today;
            if (!end.HasValue)
                end = DateTime.Now;

            return deviceRstTypeCntService.GetList(imei, start.Value, end.Value, desc.Value, index.Value, size.Value);
        }
    }
}